<?php
 
include'config.php';
$query = mysql_query('SELECT id,bookTitle,author FROM datas') or die(mysql_error()); // เลือกฐานข้อมูล และแสดงError

//$arr = mysql_fetch_assoc($query);

$data_array = array();//สร้าง array เปล่า

while($arr = mysql_fetch_object($query))//วน
{
	//$arr->id ???id
	//$arr->name ???????
	//$data_array[($arr->id)] = $arr;
	$data_array[$arr->id]['id']=$arr->id;
	$data_array[$arr->id]['bookTitle']=$arr->bookTitle;
	$data_array[$arr->id]['author']=$arr->author;
}


echo json_encode($data_array);
?>